fix(compiler): repair generic dictionary dispatch for pointer-constraint receivers - #161
Merged
Merged
Conversation
…int receivers Interface-constraint generic methods lowered a property-keyed dispatch lambda that called the method directly on the receiver value. When the caller converted the address of a variable to the constraint's pointer type-set element, the runtime receiver was a VarRef wrapper, so the call failed with TypeError: <Method> is not a function. Unwrap struct receivers through pointerValue in the dictionary lambdas; class instances pass through unchanged. Interface descriptors keep their existing shape. The same chain exposed a second lowering gap: an explicit instantiation that leaves trailing type parameters to constraint inference, such as decodeLocalPairing[*pairingOffer] over [M localPairingMessage[T], T any], emitted type arguments only for the explicitly written parameter, so the body resolved T's zero value as null and dispatched on nil. Read the full argument list recorded by go/types Instances when explicit arguments run out. Bump compilerSemanticsVersion so cached artifacts recompile with the new dispatch shape. Signed-off-by: Christian Stewart <christian@aperture.us>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Interface-constraint generic methods lowered a property-keyed dispatch lambda that called the method directly on the receiver value. When Go code converts the address of a variable to the constraint's pointer type-set element (M(&msg) over an interface embedding *T), the runtime receiver arrived as a VarRef wrapper with no method properties, so the call failed at runtime with TypeError: is not a function.
Struct receivers in dictionary method lambdas are now unwrapped through the runtime pointerValue helper before the property-keyed call; class instances pass through unchanged and interface descriptors keep their existing shape.
The same chain exposed a second lowering gap: an explicit instantiation that leaves trailing type parameters to constraint inference, such as decodeLocalPairing[*pairingOffer] over [M localPairingMessage[T], T any], emitted type arguments only for the explicitly written parameter. The generic body then resolved the remaining parameter's zero value as null and dispatched on nil, surfacing downstream as index-out-of-range failures. The lowering now reads the full argument list recorded by go/types Instances when explicit arguments run out.
compilerSemanticsVersion is bumped so cached artifacts recompile with the new dispatch shape instead of serving pre-fix output on warm builds.